<template>
  <div>
    <div id="top">
      <span class="iconfont arrow_l">&#xe603;</span>
      <h2>小U商城</h2>
      <p>
        <span class="iconfont">&#xe64a;</span>
        <span class="iconfont">&#xe614;</span>
        <i class="line"></i>
      </p>
    </div>
    <div id="sousuo">
      <span class="iconfont">&#xe60a;</span>
      <h1>
        <img src="../../../assets/img/logo.jpg" alt="" />
      </h1>
      <form action="">
        <input
          type="text"
          name="usename"
          @keydown="keydown"
          placeholder="请输入关键字"
        />
      </form>
      <b class="iconfont">&#xe626;</b>
      <span class="iconfont">&#xe63c;</span>
    </div>
    <div id="nav">
      <nav>
        <a
          v-for="item in homecate"
          :key="item.id"
          @click="goodsto(item.id)"
          href="#"
          class="cur"
          >{{ item.catename }}</a
        >
        <i class="line"></i>
      </nav>
      <p><span class="iconfont">&#xe655;&ensp;</span>分类</p>
    </div>
    <div id="banner">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="item in homebanner" :key="item.id">
          <img :src="$pre + item.img" alt="" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div id="classification">
      <ul>
        <li>
          <img src="../../../assets/img/icon_1.jpg" alt="" />
          <span>限时秒杀</span>
        </li>
        <li>
          <img src="../../../assets/img/icon_2.jpg" alt="" />
          <span>畅销产品</span>
        </li>
        <li>
          <img src="../../../assets/img/icon_3.jpg" alt="" />
          <span>品质大牌</span>
        </li>
        <li>
          <img src="../../../assets/img/icon_4.jpg" alt="" />
          <span>小U自营</span>
        </li>
        <li>
          <img src="../../../assets/img/icon_5.jpg" alt="" />
          <span>积分商城</span>
        </li>
      </ul>
    </div>
    <div id="bgcimgs">
      <div class="bg1">
        <h2>限时秒杀</h2>
        <a href="#">查看更多<i class="iconfont">&#xe607;</i></a>
        <p class="p1">每天0点场，好货秒不停</p>
        <p class="p2">
          <span>05</span>
          <i>:</i>
          <span>20</span>
          <i class="i2">:</i>
          <span>48</span>
        </p>
      </div>
      <div class="bg2">
        <h2>品牌上新</h2>
        <p class="p1">9点整，抢大牌</p>
        <span>疯抢红包<i class="iconfont">&#xe607;</i></span>
      </div>
      <div class="bg3">
        <h2>日用好物</h2>
        <p>愿君多采撷</p>
        <span>塞满奖券<i class="iconfont">&#xe607;</i></span>
      </div>
    </div>
    <div id="haohuo">
      <p>
        <span>双11尖货预购</span>
        <span>畅购全球</span>
      </p>
      <ul>
        <li><img src="../../../assets/img/img_1.png" alt="" /></li>
        <li><img src="../../../assets/img/img_2.png" alt="" /></li>
        <li><img src="../../../assets/img/img_1.png" alt="" /></li>
        <li><img src="../../../assets/img/img_2.png" alt="" /></li>
      </ul>
    </div>
    <div id="tuijian">
      <van-tabs type="card">
        <van-tab title="是否新品" class="jian">
          <van-card
            v-for="item in newGoods"
            :key="item.id"
            :price="item.price"
            :title="item.goodsname"
            :thumb="$pre + item.img"
            @click="detail(item.id)"
          ></van-card>
        </van-tab>
        <van-tab title="是否热卖">
          <van-card
            v-for="item in hotGoods"
            :key="item.id"
            :price="item.price"
            :title="item.goodsname"
            :thumb="$pre + item.img"
            @click="detail(item.id)"
            >{{ item.id }}</van-card
          >
        </van-tab>
        <van-tab title="推荐商品">
          <van-card
            v-for="item in pickGoods"
            :key="item.id"
            :price="item.price"
            :title="item.goodsname"
            :thumb="$pre + item.img"
            @click="detail(item.id)"
          ></van-card>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import { getHortgoods } from "../../../utils/api";
export default {
  data() {
    return {
      hotGoods: [],
      newGoods: [],
      pickGoods: [],
    };
  },
  methods: {
    ...mapActions({
      reqhomecate: "home/reqchangeCate",
      reqhomebanner: "home/reqchangebannercate",
      reqhomekill: "home/reqchangekillcate",
    }),
    keydown() {
      this.$router.push("/goods");
    },
    goodsto(id) {
      this.$router.push("/goods?type=1&id=" + id);
    },
    detail(id) {
      this.$router.push("detail?id=" + id);
    },
  },
  computed: {
    ...mapGetters({
      homecate: "home/cate",
      homebanner: "home/bannercate",
    }),
  },
  mounted() {
    this.reqhomecate();
    this.reqhomebanner();
    this.reqhomekill();
    getHortgoods().then((res) => {
      this.newGoods = res.data.list[0].content;
      this.hotGoods = res.data.list[1].content;
      this.pickGoods = res.data.list[2].content;
    });
  },
};
</script>

<style scoped>
.van-swipe {
  width: 100%;
  height: 100%;
}

body,
html {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  max-width: 7.5rem;
  margin: 0 auto;
}
#top {
  height: 0.64rem;
  background: #ff6040;
  display: flex;
  padding: 0.28rem 0.12rem 0.28rem 0.32rem;
  color: #ffdfd8;
  align-items: center;
}
#top h2 {
  margin: 0 1.23rem 0 2.53rem;
  font-size: 0.32rem;
}
#top .arrow_l {
  font-size: 0.34rem;
}
#top p {
  width: 1.74rem;
  height: 0.64rem;
  border: 1px solid #ff8a6f;
  box-sizing: border-box;
  border-radius: 0.54rem;
  display: flex;
  align-items: center;
  position: relative;
}
#top p span {
  width: 50%;
  height: 100%;
  text-align: center;
  line-height: 0.64rem;
}
#top p .line {
  width: 1px;
  height: 0.37rem;
  background: #ff896e;
  position: absolute;
  top: 0.12rem;
  left: 0.86rem;
}
#sousuo {
  height: 0.65rem;
  position: relative;
  background: linear-gradient(#ff674a, #ff7661);
  display: flex;
  color: #fff;
  padding: 0 0.23rem 0 0.25rem;
  justify-content: space-between;
}
#sousuo .iconfont {
  font-size: 0.44rem;
}
#sousuo img {
  width: 1.82rem;
}
#sousuo input {
  width: 3.4rem;
  height: 0.64rem;
  line-height: 0.65rem;
  text-align: left;
  font-size: 0.18rem;
  border: 0.02rem solid #e6e6e6;
  border-radius: 0.1rem;
  padding-left: 0.5rem;
  box-sizing: border-box;
}
#sousuo b.iconfont {
  font-size: 0.32rem;
  color: #999;
  position: absolute;
  left: 3.2rem;
  top: 0.15rem;
}
#sousuo input::placeholder {
  font-size: 0.26rem;
  color: #9a9a9a;
}
#nav {
  height: 0.76rem;
  background: linear-gradient(#ff7864, #ff8a7f);
  display: flex;
  padding-top: 0.33rem;
  box-sizing: border-box;
  margin-bottom: 0.2rem;
}
#nav nav {
  width: 6.2rem;
  font-size: 0.26rem;
  padding: 0 0.15rem 0 0.2rem;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  height: 0.42rem;
  background: url(../../../assets/img/line.jpg) no-repeat right top;
}
#nav nav a {
  color: #fff3f2;
}
#nav nav a.cur {
  font-weight: bold;
  position: relative;
  font-size: 0.3rem;
  margin-top: -0.05rem;
}
#nav nav i {
  position: absolute;
  background: #fff;
  width: 0.46rem;
  height: 0.04rem;
  left: 0.5rem;
  text-align: center;
  top: 2.57rem;
}
#nav p {
  width: 1.3rem;
  text-align: center;
  color: #fff3f2;
}
#nav p span {
  vertical-align: middle;
}
#banner {
  margin-bottom: 0.2rem;
  background: #fff;
}
#banner img {
  width: 100%;
  border-radius: 0.06rem;
}
#classification {
  background-color: #fff;
  padding: 0.2rem 0 0.2rem;
  box-sizing: border-box;
  margin-bottom: 0.2rem;
  height: 1.8rem;
}
#classification ul li {
  width: 1.35rem;
  float: left;
  font-size: 0.18rem;
  margin-bottom: 0.42rem;
  margin-left: 0.1rem;
  text-align: center;
}
#classification ul li:nth-child(5) {
  margin-left: 0;
}
#classification ul li img {
  width: 0.91rem;
  height: 0.91rem;
  margin-left: 0.24rem;
  margin-bottom: 0.14rem;
}
#bgcimgs {
  width: 7.1rem;
  height: 3.5rem;
  padding: 0 0.2rem 0 0.2rem;
  box-sizing: border-box;
  margin: 0 0.2rem 0.2rem 0.2rem;
}
#bgcimgs .bg1 {
  width: 3.5rem;
  height: 3.5rem;
  float: left;
  background: url(../../../assets/img/shopBG1.png) no-repeat left top;
  margin-left: -0.2rem;
  margin-right: 0.1rem;
}
#bgcimgs .bg1 h2 {
  color: #85a642;
  font-weight: bold;
  font-size: 0.3rem;
  margin: 0.2rem 0 0 0.22rem;
}
#bgcimgs .bg1 a {
  display: block;
  float: right;
  height: 0.18rem;
  font-size: 0.18rem;
  line-height: 0.18rem;
  margin: -0.26rem 0.29rem 0 0;
}
#bgcimgs .bg1 a .iconfont {
  vertical-align: top;
}
#bgcimgs .bg1 .p1 {
  margin: 0.22rem 0 0 0.22rem;
  font-size: 0.18rem;
  color: #bbd28b;
}
#bgcimgs .bg1 .p2 {
  margin: 0.1rem 0 0 0.22rem;
}
#bgcimgs .bg1 .p2 span {
  width: 0.32rem;
  height: 0.36rem;
  background: linear-gradient(#88a946, #adc875);
  color: #fff;
  line-height: 0.36rem;
  text-align: center;
  border-radius: 0.01rem;
  font-size: 0.2rem;
  padding: 0.08rem 0.05rem 0.08rem 0.07rem;
  box-sizing: border-box;
}
#bgcimgs .bg1 .p2 i {
  color: #92b152;
}
#bgcimgs .bg2 {
  width: 3.5rem;
  height: 1.7rem;
  float: right;
  margin-right: -0.2rem;
  background: url(../../../assets/img/shopBG2.png) no-repeat;
}
#bgcimgs .bg2 h2 {
  color: #ff6040;
  font-weight: bold;
  font-size: 0.3rem;
  margin: 0.2rem 0 0 0.22rem;
}
#bgcimgs .bg2 .p1 {
  color: #ffa997;
  font-size: 0.18rem;
  margin: 0.2rem 0 0 0.22rem;
}
#bgcimgs .bg2 span {
  display: block;
  width: 1.2rem;
  height: 0.4rem;
  background: linear-gradient(#ff6444, #ff9c7c);
  color: #fff;
  border-radius: 0.03rem 0.4rem 0.4rem 0.03rem;
  margin: 0.08rem 0 0 0.22rem;
  text-align: center;
  font-size: 0.18rem;
  line-height: 0.4rem;
  padding-left: 0.1rem;
}
#bgcimgs .bg2 span .iconfont {
  vertical-align: top;
  font-size: 0.18rem;
}
#bgcimgs .bg3 {
  width: 3.5rem;
  height: 1.7rem;
  float: right;
  margin: 0.1rem -0.2rem 0 0;
  background: url(../../../assets/img/shopBG3.png) no-repeat;
}
#bgcimgs .bg3 h2 {
  color: #af40ff;
  font-weight: bold;
  font-size: 0.3rem;
  margin: 0.2rem 0 0 0.22rem;
}
#bgcimgs .bg3 p {
  color: #d190ff;
  font-size: 0.18rem;
  margin: 0.2rem 0 0 0.22rem;
}
#bgcimgs .bg3 span {
  display: block;
  width: 1.2rem;
  height: 0.4rem;
  background: linear-gradient(#b94aff, #f38aff);
  color: #fff;
  border-radius: 0.03rem 0.4rem 0.4rem 0.03rem;
  margin: 0.08rem 0 0 0.22rem;
  text-align: center;
  font-size: 0.18rem;
  line-height: 0.4rem;
  padding-left: 0.1rem;
}
#bgcimgs .bg3 span .iconfont {
  vertical-align: top;
  font-size: 0.18rem;
}
#haohuo {
  width: 7.1rem;
  background-color: #fff;
  margin: 0 0 0.2rem 0.2rem;
  padding: 0 0.2rem 0.5rem 0.2rem;
  box-sizing: border-box;
}
#haohuo p {
  width: 6.7rem;
  height: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#haohuo p span:nth-child(1) {
  color: #ff6040;
  font-weight: bold;
  line-height: 0.85rem;
  margin-left: 0.85rem;
}
#haohuo p span:nth-child(2) {
  color: #a3a3a3;
  font-size: 0.24rem;
  line-height: 0.85rem;
  margin-right: 1.2rem;
}
#haohuo ul {
  width: 6.9rem;
  height: 1.8rem;
}
#haohuo ul li {
  width: 1.6rem;
  height: 1.6rem;
  float: left;
  margin-right: 0.1rem;
}
#haohuo ul li:nth-child(4) {
  margin-right: 0;
}
#haohuo ul li img {
  width: 1.6rem;
  height: 1.6rem;
  vertical-align: middle;
}
#tuijian {
  margin: 0.54rem 0.3rem 0 0.3rem;
  padding: 0 0.18rem 2.2rem;
}
#tuijian h2 {
  display: flex;
  width: 100%;
  justify-content: space-around;
}
#tuijian h2 span {
  flex: 1;
  height: 0.58rem;
  color: #f2a83b;
  font-size: 0.24rem;
  text-align: center;
  line-height: 0.58rem;
}
#tuijian h2 span:nth-child(1) {
  border-radius: 0.05rem 0 0 0.05rem;
}
#tuijian h2 span:nth-child(3) {
  border-radius: 0 0.05rem 0.05rem 0;
}
#tuijian h2 span:hover {
  background: #f2a83b;
  color: #fff;
  font-weight: bold;
}
#tuijian ul li {
  width: 5.72rem;
  height: 2.76rem;
  margin: 0.2rem auto 0;
  border: gray solid 1px;
}
#tuijian ul li img {
  float: left;
  margin-top: 14px;
  height: 2rem;
}
#tuijian ul li p {
  float: left;
  margin-left: 0.36rem;
  font-size: 0.24rem;
}
#tuijian li p span {
  display: block;
}
#tuijian li p span:nth-of-type(1) {
  margin-top: 0.25rem;
}
#tuijian li p span:nth-of-type(2) {
  margin-top: 0.2rem;
  color: rgb(243, 170, 67);
}
#tuijian li p del {
  margin-top: 0.2rem;
}
#tuijian li p button {
  width: 1.36rem;
  height: 0.46rem;
  border: none;
  border-radius: 0.05rem;
  display: block;
  margin-top: 0.2rem;
  background: #f2a83b;
  color: #fff;
}

/* #footer {
  width: 7.5rem;
  height: 1.67rem;
  border-top: 1px solid #ccc;
  background-color: #fff;
  display: flex;
  justify-content: space-around;
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 0.14rem 0 0.14rem 0;
  box-sizing: border-box;
}
#footer a {
  width: 1.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#footer i {
  display: block;
  font-size: 0.4rem;
  line-height: 0.4rem;
}
#footer span{
  color: #9c9c9c;
  font-size: 0.18rem;
  line-height: 0.18rem;
  margin-top: 0.16rem;
}
#footer .cur {
  background-color: #ff6040;
  color: #fff;
} */
</style>